package com.controller.manager;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.service.UploadFileService;

@Controller
@RequestMapping("/uploadfile")
public class UploadFileController {

	@Resource
	private UploadFileService uploadFileService;
	
	@RequestMapping(value="/uploadFile", method=RequestMethod.POST)
	@ResponseBody
	public Map<String,String> uploadFile(
			@RequestParam(value = "imgfiles", required = false) MultipartFile[] imgfiles) {
		try {
			String img = uploadFileService.uploadFile(imgfiles);
			Map<String,String> map = new HashMap<String,String>();
			map.put("img", img);
			return map;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
}
